package com.qs.dao;

import java.util.List;

import com.infomanage.bean.FieldBean;
import com.infomanage.bean.SearchBean;
import com.infomanage.dao.BaseDAO;
import com.infomanage.exception.DaoException;
import com.infomanage.po.HibernateSessionFactory;
import com.qs.po.QsRecRuntime;


public class QsRecRuntimeDAO extends BaseDAO<QsRecRuntime> {

	public QsRecRuntime find(int id) throws DaoException {
		try {
			SearchBean searchBean  = new SearchBean();
			FieldBean fieldBean  = new FieldBean();
			fieldBean.setName("id");
			fieldBean.setValue(id);
			searchBean.add(fieldBean);
			return super.find(QsRecRuntime.class, id);
		} catch (Exception e) {
			throw new DaoException(e);
		} finally {
			HibernateSessionFactory.closeSession();
		}
	}
	
	public List<QsRecRuntime> findByType(int type) throws DaoException {
		try {
			SearchBean searchBean  = new SearchBean();
			FieldBean fieldBean  = new FieldBean();
			fieldBean.setName("type");
			fieldBean.setValue(type);
			searchBean.add(fieldBean);
			return super.findByFields(QsRecRuntime.class, searchBean);
		} catch (Exception e) {
			throw new DaoException(e);
		} 
	}
	
	public List<QsRecRuntime> findAll() throws DaoException {
		try {
			return super.findAll(QsRecRuntime.class);
		} catch (Exception e) {
			throw new DaoException(e);
		} 
	}
	
	
	public int count(SearchBean searchBean) throws DaoException{
		return super.count(QsRecRuntime.class, searchBean);
	}
}
